/*
	The MIT License

	Copyright (c) 2010 IFMO/GameDev Studio

	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in
	all copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
	THE SOFTWARE.
*/

#pragma once


/*-----------------------------------------------------------------------------
	GL model :
-----------------------------------------------------------------------------*/

class	EGLVertexBuffer : public IVertexBuffer {
	public:
								EGLVertexBuffer		( EGLVBManager *mss, EGLDriver *driver );
								~EGLVertexBuffer	( void );
						
		virtual void			UpdateFromMesh		( const IPxTriMesh mesh, bool update_only_verts=false );
		virtual void			DrawTris			( uint start_tri, uint num_tris ) const;
		virtual void			DrawAllTris			( void ) const;
		
	protected:
		void			FreeBuffers		( void );
		
		uint			vertex_num;
		uint			index_num;
		uint			total_tri_num;
	
		GLuint			vertex_buffer_id;
		GLuint			index_buffer_id;
		
		struct GLVertex {
			EPoint		pos;
			EVector		normal;
			EVector		tangent;
			EVector		binormal;
			ETexCoord   uv;
			EColor		color;
			EColor		blend_weights;
			EColor		blend_indices;
		};
		
		//void			ReleaseModel	( void );
	
		//EGLDriver			*driver;
		//EGLVBManager		*mss;
		//IDirect3DDevice9	*d3ddev;
		
		//IDirect3DVertexDeclaration9	*decl;

		//uint	num_verts;
		//uint	num_tris;
		//uint	num_inds;
		
		//IDirect3DIndexBuffer9		*ib;
		//IDirect3DVertexBuffer9		*vb;
	};